package org.tacademy.and12th.jyh.buckeybuckey;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class BadgeImageAdapter extends BaseAdapter {

	private Context mContext;
	
	public static Integer[] BadgeThumbIds = {
				R.drawable.badge_follow, R.drawable.badge_love,
				R.drawable.badge_n_tower, R.drawable.badge_pizza,
				R.drawable.badge_xmas
				};
	
	public static Integer[] BadgeTextIds = {
				R.string.travel_two, R.string.travel_five,
				R.string.travel_eight, R.string.challenge_two,
				R.string.challenge_five
				};
	public BadgeImageAdapter(Context c ) {
		mContext = c;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return BadgeThumbIds.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return BadgeThumbIds[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return BadgeThumbIds[position];
	}
	
	public long getItemTextId(int position) {
		// TODO Auto-generated method stub
		return BadgeTextIds[position];
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ImageView BadgeView;
		
//		TextView BadgeText;
		if (convertView == null) {
			BadgeView = new ImageView(mContext);
			BadgeView.setLayoutParams(new GridView.LayoutParams(200, 200));
			BadgeView.setScaleType(ImageView.ScaleType.CENTER_CROP);
			BadgeView.setPadding(10,10,10,10);
		
		} else {
			BadgeView = (ImageView) convertView;
			
		}
		BadgeView.setTag(String.valueOf(position));
		BadgeView.setImageResource(BadgeThumbIds[position]);
	
//		BadgeText.setText(BadgeTextIds[position]);
		
		return BadgeView;
	}
	

}
